## test Bayesian lasso
## (c) Yongjin Park, 2013
require(glmnet)
require(lars)
require(Matrix)

demo <- function( n, K, p=.9 )
  {
    c <- round( n/K )
    n <- max( n, K*c )

    stopifnot( c > 2 ) # give up for too small group size

    A <- spMatrix( nrow=n, ncol=n )

    for( k in 1:K )
      {
        idx <- (1 + (k-1)*c):(k*c)
        A[idx,idx] <- runif( n=c*c )
      }

    A <- triu(A, k=1)
    A <- A + t(A)
    A[ A > p ] <- 0
    A[ A > 0 & A <= p ] <- 1
    return( A )
  }


################################################################
A <- demo( n=10, K=2 )







################################################################

dat <- read.table( 'diabetes.std.txt' )
X <- as.matrix(dat[,1:10])
y <- as.matrix(dat[,11])
n <- dim(X)[1]
p <- dim(X)[2]


glm.out <- glmnet( X, y, family="gaussian" )




